package com.yaokai.springbootreabbitmq.consumer;

import com.rabbitmq.client.Channel;
import com.yaokai.springbootreabbitmq.config.DelayedQueryConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.Date;

/**
 * 消费者 - 死信队列
 * @author zhiyuan
 */
@Slf4j
@Component
public class DeadLetterQueueConsumer {

    @RabbitListener(queues = "QD")
    public void receiveD(Message message, Channel channel) throws IOException {
        String msg = new String(message.getBody());
        log.info("当前时间：{},收到死信队列信息{}", new Date().toString(), msg);
    }

    @RabbitListener(queues = DelayedQueryConfig.DELAYED_QUERY)
    public void delayedQUERY(Message message, Channel channel) throws IOException {

        String msg = new String(message.getBody());
        log.info("当前时间：{},收到插件延时队列信息{}", new Date().toString(), msg);
    }

}